﻿// Copyright (c) 2014 Jonathan Magnan (http://jonathanmagnan.com/).
// All rights reserved (http://zzzproject.com/sqlbulkcopy-extensions/).
// Licensed under MIT License (MIT) (https://zsqlbulkcopy.codeplex.com/license/).
using System.Collections.Generic;
using System.Data;

namespace Z.Net.Extensions
{
    internal partial class SqlBulkOperation
    {
        public bool IsBulkStategy()
        {
            if (Config.MinRecord > 0)
            {
                if (DataSource is DataTable)
                {
                    return ((DataTable) DataSource).Rows.Count >= Config.MinRecord;
                }
                if (DataSource is DataRow[])
                {
                    return ((DataRow[]) DataSource).Length >= Config.MinRecord;
                }
                if (DataSource is IEnumerable<object>)
                {
                    return DataSourceAsList.Count >= Config.MinRecord;
                }
            }

            return true;
        }
    }
}